package ast.nodes.commandNodes;

import scanner.Token;
import ast.Evaluation;
import ast.nodes.CommandNode;

public class SubstringNode extends CommandNode {

    public SubstringNode()
    {
        super();
    }
    
    public SubstringNode(Token data)
    {
        super(data);
    }
    
    /**
     * substring(x,y) replaces LINE with the substring of LINE from index x (inclusive)
     * to index y (exclusive). The special value EOL may be used to represent the end
     * of LINE (not the last character!).
     */
    @Override
    public void run(Evaluation input) {
        int i = Integer.parseInt(children.get(0).getData().getTokenString());
        Token second = children.get(1).getData();
        switch(second.getType()){
        	case INTEGER:
        		input.substring(i, Integer.parseInt(second.getTokenString()));
        		break;
        	case EOL:
        		input.substring(i, input.length());
        		break;
        }
    }
}
